package com.example.shopping_web_back.mapper;

import com.example.shopping_web_back.pojo.BrowsingHistory;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface BrowsingHistoryMapper {

    @Select("select * from shoppingweb.browsing_history where business_name=#{businessName}")
    List<BrowsingHistory> list(String businessName);

    @Insert("insert into shoppingweb.browsing_history(goods_name, business_name, customer_name, browsing_time, image) values "
            + "(#{goodsName}, #{businessName}, #{customerName}, #{browsingTime}, #{image})")
    void addBrowsingHistory(BrowsingHistory browsingHistory);

    @Delete("delete from shoppingweb.browsing_history where customer_name=#{customerName} and business_name=#{businessName} and goods_name=#{goodsName} and browsing_time=#{browsingTime}")
    void deleteBrowsingHistory(BrowsingHistory browsingHistory);
}
